<%@ page language="java" import="java.util.*" pageEncoding="UTF-8" isELIgnored="false"%>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core"%>
<%@ taglib prefix="s" uri="http://www.springframework.org/tags" %>

<!doctype html>
<html>
  <head>
    
    <link rel="stylesheet" href="<s:url value="/resources"/>/css/innerstyle.css" type="text/css" />
    <link rel="stylesheet" type="text/css" media="screen" href="<s:url value="/resources"/>/css/custom-theme/jquery-ui.custom.min.css" />	
	<script type="text/javascript" src="<s:url value="/resources"/>/js/jquery-1.7.2.min.js"></script>
	<script type="text/javascript" src="<s:url value="/resources"/>/js/jquery-ui.custom.min.js"></script> 
	<script type="text/javascript" src="<s:url value="/resources"/>/js/i18n/jquery.ui.datepicker-zh-CN.js"></script>
<style type="text/css">
html, body {
	margin: 0;			 
	padding: 0;	 
    font-size: 85%;
}
#tab{
	width:99%;	
	padding:0 2px 3px 2px;
	margin:0;
	float:left;
}
#tab h1{
	display:block;
	width:95%;
	height:45px;	
	float:center;
	text-align: center;
	padding-top:5px;
}
#tab h1 span{
	width:250px;
	font:bold 26px/55px Arial, Helvetica, sans-serif;
	color:#fff;
	background-color:#fff;
	display:block;
}
.content1
{
	margin:0px;	
	padding:0px;
	width:100%;	
	font-size:12px;	
}
.content1 td
{    
    height:16px;
	line-height:10px;
	text-align:left;
	border-top-style:none;
	border-left-style:none;
	border-right-style:none;
	border-bottom-style:none;
}

label{ display:block; }
fieldset { padding:0; border:0; margin-top:25px; }
label.error {  
        color: red;/*错误信息的颜色*/  
    }  
input.error {  
        border:1px dotted red;/*输入错误的输入框的边框样式*/  
    }		
	
	</style>

</head>
<script type='text/javascript'>
  
  
  	$(function (){	
  	$("#but1").button(); 
    $("#but2").button();
    $("#but3").button();
    $("#but4").button();
    $("#gaizhang").button();
    //checkJg();
 			$("#cmrqz").hide();
	    	$("#msrqz").hide();
	    	$("#zxqz").hide();
	    	showyinzhang(0);
	    	showyinzhang(1);
	    	showyinzhang(2);
		
		$("#but2").click((function (){	
			var zt=$("#zhuangt").val();
			if(zt=="1"){
				var url= "<s:url value="/"/>/htgl/backDsht";
				$.post(url, {
					hetid : $("#htbh").val()
				}, function(data, textStatus) {				
					var json = eval('(' + data + ')');
					if (json.result == "1") {
						alert("退回成功");
						window.location.reload();
						//window.opener.document.location.reload();
					} else {
						alert("退回失败");
					}

				});
				
			}else{
				alert("合同状态为待确认才可退回！");
			}
			
  	 		
			
	}));
		
  	 $("#but1").click((function (){ 	
  		var zt=$("#zhuangt").val();
		if(zt=="1"){
			var url= "<s:url value="/"/>/htgl/reviewDsht";
			$.post(url, {
				hetid : $("#htbh").val()
			}, function(data, textStatus) {
				var json = eval('(' + data + ')');
				if (json.result == "1") {
					alert("确认成功。请进行签章操作。");
					window.location.reload();
					//window.opener.document.location.reload();
				} else {
					alert("确认失败");
				}

			});
			
		}else{
			alert("合同状态为待确认才可确认！");
		}
  	 
		}));
  	
  	
	});
	
	
	
	
	
  	function addyinzhang(hetbh,zt) {
   	 if(zt=="0"||zt=="6"||zt=="1"){
   		 alert("合同须在确认后才能签章！");
   	 }else{
   		 var url = "<s:url value="/"/>/htgl/saveHtqz";
   	    	$.post(url,{ hetid:'${htinfo.hetid}'},function(data){   
   	              var json =eval('(' + data + ')');
   				   if(json.result==1){
   					   showyinzhang(0);		
   				      alert("出卖人签章成功！");
   				      	   
   				   }else if(json.result==2){
   					   showyinzhang(1);
   					   alert("买受人签章成功！");
   					  
   				   }else if(json.result==3){
   				      alert("出卖人已签章！");
   				   }else if(json.result==4){
   				      alert("买受人已签章！");    
   				   }else if(json.result==5){
   				      alert("合同信息不符！");
   				   }else if(json.result==6){
   				      alert("无印章信息！");
   				   }else{
   					    alert("签章失败！");
   	              }
   	    	});
   	 }
   	
     }
      
   function showyinzhang(qzlx){
   	//1买2中心0卖
   	//alert(qzlx);
	
   	var url = "<s:url value="/"/>/htgl/loadqzinfo";
   	$.post(url,{ hetid:'${htinfo.hetid}', qzlx: qzlx },function(data){   
   		var json = eval('(' + data + ')');
   		
   		var yinzhang=json.result;
   		
   		if(qzlx=="0"){
	    		
	    		if(yinzhang!=""){
	    			
	    			$("#cmrqz img").attr("src","data:image/gif;base64,"+yinzhang);
		    		$("#cmrqz").show();
	    		}
	    		
	    	}
	    	if(qzlx=="1"){
	    		//
	    		if(yinzhang!=""){
		    		$("#msrqz img").attr("src","data:image/gif;base64,"+yinzhang);
		    		$("#msrqz").show();
	    		}
	    	}
	    	if(qzlx=="2"){
	    		//
	    		if(yinzhang!=""){
		    		$("#zxqz img").attr("src","data:image/gif;base64,"+yinzhang);
		    		$("#zxqz").show();
	    		}
	    	}
   	});
   	
   }
   
	 
</script>
<body>
	<div id="tab">
	<p><img src="<s:url value="/resources"/>/img/bcxyhtlc.gif" width="1200" height="30"></p>
		<h1>补充协议</h1>
		<form name="form2" id="form2">
		<input type="hidden" name="aouserid" id="aouserid" value="${aouserid}"> 
<input type="hidden" name="aousername" id="aousername" value="${aousername}"> 
<input type="hidden" name="authtoken" id="authtoken" value="${authtoken}"> 
<input type="hidden" name="zhuangt" id="zhuangt" value="${htinfo.zhuangt}"> 
<input type="hidden" name="caozr" id="caozr" value="${htinfo.caozr}"> 
			<table id="list_search" cellpadding="0" cellspacing="0" border="0">
				<tr>
					<td>出卖人（销方）:</td>
					<td>${htinfo.chumdwmc}</td>
					<td>企业合同号:</td>
					<td>${htinfo.hetlrbh}
					</td>
					<td>发站:</td>
					<td>${htinfo.fazmch}
					</td>
				</tr>

				<tr>
					<td>买受人（购方）:</td>
					<td>${htinfo.maisdwmc} <a  href="javascript:NBuilderIM_openChatBox(${htinfo.caozr});" style="height:50px;" id="chat"> <img class="NBuilderIMToChat" ></a>
					</td>
					<td>签约地点:</td>
					<td>中国(太原)煤炭交易中心
					</td>
					<td>到站:</td>
					<td>${htinfo.daozmch}</td>
				</tr>
				<tr>
					<td>合同形式:</td>
					<td>${htinfo.hetxsname}</td>
					<td>价格类型:</td>
					<td>${htinfo.jiaglxmc}</td>
					<td>隶属:</td>
					<td>${htinfo.hangylsname}</td>
				</tr>

				<tr>
					<td>发货单位:</td>
					<td>${htinfo.fahdwmc}</td>
					<td>到达省市:</td>
					<td>${htinfo.daodssdmc}</td>
					<td>签订时间:</td>
					<td>${htinfo.qianysj}
					</td>

				</tr>
				
				<tr>
					<td>是否中长期合同:</td>
					<td>  <c:if test="${htinfo.iszcx==0}">否</c:if><c:if test="${htinfo.iszcx==1}">是</c:if></td>
				</tr>

				<tr>
					<td colspan="6" style="padding-top:5px;">一、收货人名称、品种规格、数量、单价</td>
				</tr>
				<tr>
					<td colspan="6" style="padding:1px;">
						<table id="changdi" align="center" cellpadding="0" cellspacing="0"
							class="content_gridview">
							<thead>
								<tr>
									<th rowspan="3">收货人名称</th>
									<th rowspan="3">品种规格</th>
									<th rowspan="3">质量指标</th>
									<th rowspan="3">价格<br/>(元/吨)</th>
									<th colspan="13">交（提）货时间、煤量（吨）</th>

								</tr>
								<tr>
									<th rowspan="2">全年合计</th>
									<th colspan="3">一季度</th>
									<th colspan="3">二季度</th>
									<th colspan="3">三季度</th>
									<th colspan="3">四季度</th>
								</tr>
								<tr>
									<th>1</th>
									<th>2</th>
									<th>3</th>
									<th>4</th>
									<th>5</th>
									<th>6</th>
									<th>7</th>
									<th>8</th>
									<th>9</th>
									<th>10</th>
									<th>11</th>
									<th>12</th>
								</tr>
							</thead>
							<tbody>
								
									<tr>
										<td>
										${htinfo.shouhdwmc}								
									  </td>
										<td>										
										${htinfo.pinzgg} 										
										</td>
										<td>${htinfo.zhilzb}</td>
										<td>${htinfo.jiag}
										</td>
										<td>
										<c:choose>  
										 <c:when test="${htinfo.shul == ''}">
										     0
										 </c:when>  
										 <c:otherwise>
										     ${htinfo.shul}
										 </c:otherwise>  
									   </c:choose>  
										</td>
										<td>
										 <c:choose>  
											 <c:when test="${htinfo.gml1 == '' || empty htinfo.gml1}">
											     0
											 </c:when>  
											 <c:otherwise>
											     ${htinfo.gml1}
											 </c:otherwise>  
									     </c:choose>  
										</td>
										<td>
										 <c:choose>  
											 <c:when test="${htinfo.gml2 == '' || empty htinfo.gml2}">
											     0
											 </c:when>  
											 <c:otherwise>
											     ${htinfo.gml2}
											 </c:otherwise>  
									     </c:choose>
										</td>
										<td>
										   <c:choose>  
											 <c:when test="${htinfo.gml3 == '' || empty htinfo.gml3}">
											     0
											 </c:when>  
											 <c:otherwise>
											     ${htinfo.gml3}
											 </c:otherwise>  
									     </c:choose>
										</td>
										<td>
										<c:choose>  
											 <c:when test="${htinfo.gml4 == '' || empty htinfo.gml4}">
											     0
											 </c:when>  
											 <c:otherwise>
											     ${htinfo.gml4}
											 </c:otherwise>  
									     </c:choose>
										</td>
										<td>
										  <c:choose>  
											 <c:when test="${htinfo.gml5 == '' || empty htinfo.gml5}">
											     0
											 </c:when>  
											 <c:otherwise>
											     ${htinfo.gml5}
											 </c:otherwise>  
									     </c:choose>
										</td>
										<td>
										<c:choose>  
											 <c:when test="${htinfo.gml6 == '' || empty htinfo.gml6}">
											     0
											 </c:when>  
											 <c:otherwise>
											     ${htinfo.gml6}
											 </c:otherwise>  
									     </c:choose>
										</td>
										<td>
										  <c:choose>  
											 <c:when test="${htinfo.gml7 == '' || empty htinfo.gml7}">
											     0
											 </c:when>  
											 <c:otherwise>
											     ${htinfo.gml7}
											 </c:otherwise>  
									     </c:choose>
										</td>
										<td>
										<c:choose>  
											 <c:when test="${htinfo.gml8 == '' || empty htinfo.gml8}">
											     0
											 </c:when>  
											 <c:otherwise>
											     ${htinfo.gml8}
											 </c:otherwise>  
									     </c:choose>
										</td>
										<td>
										<c:choose>  
											 <c:when test="${htinfo.gml9 == '' || empty htinfo.gml9}">
											     0
											 </c:when>  
											 <c:otherwise>
											     ${htinfo.gml9}
											 </c:otherwise>  
									     </c:choose>
										</td>
										<td>
										<c:choose>  
											 <c:when test="${htinfo.gml10 == '' || empty htinfo.gml10}">
											     0
											 </c:when>  
											 <c:otherwise>
											     ${htinfo.gml10}
											 </c:otherwise>  
									     </c:choose>
										</td>
										<td>
										<c:choose>  
											 <c:when test="${htinfo.gml11 == '' || empty htinfo.gml11}">
											     0
											 </c:when>  
											 <c:otherwise>
											     ${htinfo.gml11}
											 </c:otherwise>  
									     </c:choose>
										</td>
										<td>
										<c:choose>  
											 <c:when test="${htinfo.gml12 == '' || empty htinfo.gml12}">
											     0
											 </c:when>  
											 <c:otherwise>
											     ${htinfo.gml12}
											 </c:otherwise>  
									     </c:choose>
										</td>
									</tr>
							</tbody>
						</table></td>
				</tr>

				<tr>
					<td colspan="6">
						<table id="djtk" cellpadding="0" cellspacing="0" border="0"
							class="content1">							
							<c:forEach var="tk" items="${djtk}">
								<tr>
									<td width="450px">${tk.xh}${tk.biaot}</td>
									<td style="width:80%;height:45px"><div>${tk.neir}</div></td>									
								</tr>
							</c:forEach>							
						</table></td>
				</tr>
				<tr>
					<td colspan="6">
						<table cellpadding="0" cellspacing="0" style="width:100%"
							class="content_gridview">
							<thead>
								<tr>
									<th colspan="2">出卖人</th>
									<th colspan="2">买受人</th>
									
								</tr>
							</thead>
							<tbody>
								<tr>
									<td>
										<table cellpadding="0" cellspacing="0" border="0" id="sjsdnr"
											class="content1">
											<tr>
												<td>出卖人名称(章)：</td>
												<td>${htinfo.chumdwmc}</td>
											</tr>
											<tr>
												<td>住 所:</td>
												<td>${htinfo.chumdwdz}</td>
											</tr>
											<tr>
												<td>法定代表人:</td>
												<td>${htinfo.chumdwfddbr}</td>
											</tr>
											<tr>
												<td>委托代理人:</td>
												<td>${htinfo.chumdwwtdlr}</td>
											</tr>
											<tr>
												<td>电 话:</td>
												<td>${htinfo.chumdwdh}</td>
											</tr>
											<tr>
												<td>传真:</td>
												<td>${htinfo.chumdwcz}</td>
											</tr>
											<tr>
												<td>邮政编码:</td>
												<td>${htinfo.chumdwyzbm}</td>
											</tr>
											<tr>
												<td>开户银行:</td>
												<td>${htinfo.chumdwkhyh}</td>
											</tr>
											<tr>
												<td>帐号:</td>
												<td>${htinfo.chumdwzh}</td>
											</tr>
											<tr>
												<td>纳税人登记号:</td>
												<td>${htinfo.chumdwnsrdjh}</td>
											</tr>
										</table></td>
									<td><table cellpadding="0" cellspacing="0" border="0" id="sjsdnr1"
											class="content1">
											<tr>
												<td>出卖人结算单位名称(章)：</td>
												<td>${htinfo.chumdwjsrmc}</td>
											</tr>
											<tr>
												<td>住 所:</td>
												<td>${htinfo.chumdwjsrdz}</td>
											</tr>
											<tr>
												<td>法定代表人:</td>
												<td>${htinfo.chumdwjsrfddbr}</td>
											</tr>
											<tr>
												<td>委托代理人:</td>
												<td>${htinfo.chumdwjsrwtdlr}</td>
											</tr>
											<tr>
												<td>电 话:</td>
												<td>${htinfo.chumdwjsrdh}</td>
											</tr>
											<tr>
												<td>传真:</td>
												<td>${htinfo.chumdwjsrcz}</td>
											</tr>
											<tr>
												<td>邮政编码:</td>
												<td>${htinfo.chumdwjsryzbm}</td>
											</tr>
											<tr>
												<td>开户银行:</td>
												<td>${htinfo.chumdwjsrkhyh}</td>
											</tr>
											<tr>
												<td>帐号:</td>
												<td>${htinfo.chumdwjsrzh}</td>
											</tr>
											<tr>
												<td>纳税人登记号:</td>
												<td>${htinfo.chumdwjsrnsrdjh}</td>
											</tr>

										</table>									</td>
									<td><table cellpadding="0" cellspacing="0" border="0" id="bjsdnr"
											class="content1">
											<tr>
												<td>买受人名称(章)：</td>
												<td>${htinfo.maisdwmc}</td>
											</tr>
											<tr>
												<td>住 所:</td>
												<td>${htinfo.maisdwdz}</td>
											</tr>
											<tr>
												<td>法定代表人:</td>
												<td>${htinfo.maisdwfddbr}</td>
											</tr>
											<tr>
												<td>委托代理人:</td>
												<td>${htinfo.maisdwwtdlr}</td>
											</tr>
											<tr>
												<td>电 话:</td>
												<td>${htinfo.maisdwdh}</td>
											</tr>
											<tr>
												<td>传真:</td>
												<td>${htinfo.maisdwcz}</td>
											</tr>
											<tr>
												<td>邮政编码:</td>
												<td>${htinfo.maisdwyzbm}</td>
											</tr>
											<tr>
												<td>开户银行:</td>
												<td>${htinfo.maisdwkhyh}</td>
											</tr>
											<tr>
												<td>帐号:</td>
												<td>${htinfo.maisdwzh}</td>
											</tr>
											<tr>
												<td>纳税人登记号:</td>
												<td>${htinfo.maisdwnsrdjh}</td>
											</tr>

										</table>									</td>
									<td><table cellpadding="0" cellspacing="0" border="0" id="bjsdnr1"
											class="content1">
											<tr>
												<td>买受人结算单位名称(章)：</td>
												<td>${htinfo.maisdwjsrmc}</td>
											</tr>
											<tr>
												<td>住 所:</td>
												<td>${htinfo.maisdwjsrdz}</td>
											</tr>
											<tr>
												<td>法定代表人:</td>
												<td>${htinfo.maisdwjsrfddbr}</td>
											</tr>
											<tr>
												<td>委托代理人:</td>
												<td>${htinfo.maisdwjsrwtdlr}</td>
											</tr>
											<tr>
												<td>电 话:</td>
												<td>${htinfo.maisdwjsrdh}</td>
											</tr>
											<tr>
												<td>传真:</td>
												<td>${htinfo.maisdwjsrcz}</td>
											</tr>
											<tr>
												<td>邮政编码:</td>
												<td>${htinfo.maisdwjsryzbm}</td>
											</tr>
											<tr>
												<td>开户银行:</td>
												<td>${htinfo.maisdwjsrkhyh}</td>
											</tr>
											<tr>
												<td>帐号:</td>
												<td>${htinfo.maisdwjsrzh}</td>
											</tr>
											<tr>
												<td>纳税人登记号:</td>
												<td>${htinfo.maisdwjsrnsrdjh}</td>
											</tr>

										</table>									</td>
									
								</tr>
							</tbody>
						</table></td>

				</tr>
				<tr>
					<td colspan="4"><font size="2" color="#FF0000"></font>
					</td>
					<td colspan="2" align="right"><font size="2">合同有效期：${htinfo.youxqxkssj} 至 ${htinfo.youxqxjssj} </font>
					</td>
				</tr>



				<tr>
					<td colspan="6" align="center">
					<!--  <input type="button" id="jsdnr1" value="隐藏">
		            <input type="button" id="jsdnr" value="展开">&nbsp;&nbsp;&nbsp;-->
		            <input type="hidden" name="hetid" value="${htinfo.hetid}" id="htbh">	
		            <input id="but4" type="button" name="" value="刷新" onclick="window.location.reload(); "/> &nbsp;&nbsp;&nbsp;					
					<input id="but1" type="button" name="" value="确认" /> &nbsp;&nbsp;&nbsp;
					<input id="but2" type="button" name="" value="退回" /> &nbsp;&nbsp;&nbsp;
					<input name="" type="button" id="gaizhang" value="签章" onclick="addyinzhang('${htinfo.hetbh}','${htinfo.zhuangt}');" />	&nbsp;&nbsp;&nbsp;				    
					<input id="but3" type="button" name="" value="关闭" onclick="window.returnValue=1;window.close();" />
					</td>
				</tr>

			</table>
		</form>
</div>
<div
		style="position:absolute;top:700px;left:350px;width:200px;height:200px;"
		id="cmrqz">
		<img src="" alt="" width="200" height="200" />
	</div>
	<div
		style="position:absolute;top:700px;left:950px;width:200px;height:200px;"
		id="msrqz">
		<img src="" alt="" width="200" height="200" />
	</div>
	<div
		style="position:absolute;top:700px;left:1200px;width:200px;height:200px;"
		id="zxqz">
		<img src="" alt="" width="200" height="200" />
	</div>
<script src="http://10.1.22.223:8020/js/sea.js"></script>
	<script>
	var aouserid=document.getElementById("aouserid").value;
	var aousername=document.getElementById("aousername").value;
	var authtoken=document.getElementById("authtoken").value;
        var NBuilder_IMconfig = {
            server: "http://10.1.22.223:8020",
            user: {
                id: aouserid,//当前用户id
                name: aousername,//当前用户姓名
                face: "http://10.1.22.223:8021/DownloadFile.ashx?file=CTCTCECP\20150608\160543zb.jpg"//头像
            },
            token:authtoken
        };
        
            seajs.use(NBuilder_IMconfig.server + "/js/im/im", function () {
                $(".NBuilderIMToChat").attr("src", NBuilder_IMconfig.server + "/image/imonline.png").css("border", "none");

                /*启动后自动打开聊天窗口
                //var touserid=2
                //NBuilderIM_openChatBox(touserid);
                */
                NBuilderIM_openChatBox(${htinfo.caozr});

            }); 
    </script>
	<div id="dialog-confirm" title="是否确定确认合同？"></div>
</body>
</html>
